/**
 * Copyright (C), 2018-2020
 * FileName: ImageUtil
 * Author:   Lee
 * Date:     2020/6/16 15:48
 * Description: 图片处理工具类
 * History:
 */
package com.cjj.common.utils;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Lee
 * @create 2020/6/16
 * @since 1.0.0
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ImageUtil {

    private static final String src = "\"//img.alicdn.com/tps/i2/TB1SN33GVXXXXarapXX0deX8pXX-900-600.png\" data-ks-lazyload=";

    public static String replaceImg(String html, Integer sourceId){
        if(sourceId == 1 || sourceId == 11){
            //淘宝的图片取懒加载图片
            Pattern p = Pattern.compile(src);
            Matcher matcher = p.matcher(html);
            html = matcher.replaceAll("");
        }
        return html;
    }

}